unit U_MasrafMerkezi;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
  cxDataStorage, cxEdit, DB, cxDBData, cxCheckBox, ActnList, ADODB,
  StdCtrls, Buttons, cxGridLevel, cxGridCustomTableView, cxGridTableView,
  cxGridDBTableView, cxClasses, cxControls, cxGridCustomView, cxGrid, Menus,
  siComp;

type
  TfmMasrafMerkezi = class(TForm)
    cxgrid1: TcxGrid;
    cxgrid1DBTableView1: TcxGridDBTableView;
    cxgrid1DBTableView1id: TcxGridDBColumn;
    cxgrid1DBTableView1MASKODU: TcxGridDBColumn;
    cxgrid1DBTableView1MASACIKLAMA: TcxGridDBColumn;
    cxgrid1DBTableView1OZELKOD1: TcxGridDBColumn;
    cxgrid1DBTableView1OZELKOD2: TcxGridDBColumn;
    cxgrid1DBTableView1AKTIF: TcxGridDBColumn;
    cxgrid1Level1: TcxGridLevel;
    bKapat: TBitBtn;
    bSil: TBitBtn;
    adoListe: TADOQuery;
    DSLISTE: TDataSource;
    ActListe: TActionList;
    acSil: TAction;
    acKapat: TAction;
    adoSil: TADOQuery;
    adoTemp: TADOQuery;
    cxgrid1DBTableView1YETKIKOD: TcxGridDBColumn;
    BitBtn2: TBitBtn;
    acYeni: TAction;
    acDuzelt: TAction;
    cxgrid1DBTableView1OZELKOD3: TcxGridDBColumn;
    PM: TPopupMenu;
    Ekle1: TMenuItem;
    Sil1: TMenuItem;
    procedure FormShow(Sender: TObject);
    procedure bKapatClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure BitBtn2Click(Sender: TObject);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure cxgrid1DBTableView1ColumnHeaderClick(
      Sender: TcxGridTableView; AColumn: TcxGridColumn);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fmMasrafMerkezi: TfmMasrafMerkezi;

implementation

uses ana1;

{$R *.dfm}

procedure TfmMasrafMerkezi.FormShow(Sender: TObject);
begin

adoListe.close;
adoListe.sql.Text:=' Select * from CS_MUH_MASRAF_MERKEZI  order by MASKODU ';
adoliste.Open;
end;

procedure TfmMasrafMerkezi.bKapatClick(Sender: TObject);
begin
 close;
end;

procedure TfmMasrafMerkezi.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  Action := cafree;
  fmMasrafMerkezi:= nil; 
end;

procedure TfmMasrafMerkezi.BitBtn2Click(Sender: TObject);
begin
 adoliste.Append;
end;

procedure TfmMasrafMerkezi.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
   if key=27 then Close;
end;

procedure TfmMasrafMerkezi.cxgrid1DBTableView1ColumnHeaderClick(
  Sender: TcxGridTableView; AColumn: TcxGridColumn);
begin
 If AColumn.SortOrder = soAscending Then
  Begin
    adoListe.sort := copy(AColumn.Name, 20, length(AColumn.Name) - 19) + ' DESC'
  End
  Else
  Begin
    adoListe.sort := copy(AColumn.Name, 20, length(AColumn.Name) - 19) + ' ASC';
  End;

  cxgrid1DBTableView1.OptionsBehavior.IncSearchItem := AColumn;
end;

end.